<?php
include_once "../common.php";


// check website location
if(!url_exists($_POST['website']))
{
	$error['Website'] = 'Website adres klopt niet';
}
// check alg.voorwarden
if(!url_exists($_POST['urlalg']))
{
	$error['Algemenevoorwaarden'] = 'Algemenevoorwaarden adres klopt niet';
}

// email,
if(!isset($_POST['email']) || empty($_POST['email']))
	$error['E-mail'] = 'Moet verplicht worden opgegeven';
// 
// name
if(!isset($_POST['name']) || empty($_POST['name']))
	$error['Naam'] = 'Moet verplicht worden opgegeven';

if(!isset($error))
{
	// save
	$query = "	INSERT INTO Webshops (
					CustomerID,
					Name,
					Email,
					URLALG,
					Website,
					URL,
					Tel,
					CreateDate
				) VALUES (
					'".str_replace("'","",$_SESSION['login']['ID'])."',
					'".str_replace("'","",$_POST['name'])."',
					'".str_replace("'","",$_POST['email'])."',
					'".str_replace("'","",$_POST['urlalg'])."',
					'".str_replace("'","",$_POST['website'])."',
					'".str_replace("'","",$_POST['website'])."',
					'".str_replace("'","",$_POST['phone'])."',
					NOW()
				)";
	$_MySQL->runQuery($query);
	echo "succes";
}
else
{
	foreach($error AS $what => $why)
	{
		echo $what.': '.$why."\n";
	}	
}